package com.cloud.custom.tasklist.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cloud.custom.common.result.SelectItem;
import com.cloud.custom.interfaces.FeignClientSystem;
import com.cloud.custom.tasklist.entity.TaskListField;
import com.cloud.custom.tasklist.service.TaskListCacheService;
import com.cloud.custom.tasklist.service.TaskListFieldService;

@Service
public class TaskListCacheServiceImpl implements TaskListCacheService {

	@Autowired
	private FeignClientSystem feignClientSystem;

	@Autowired
	private TaskListFieldService taskListFieldService;

	@Override
	public List<SelectItem> listSelectItems(String dictKey) {
		return feignClientSystem.loadDictItems(dictKey);
	}

	@Override
	public List<TaskListField> listTaskListFields(long taskListId) {
		return taskListFieldService.listFields(taskListId);
	}

	@Override
	public Map<String, String> listDictReverseMap(String dictKey) {
		List<SelectItem> items = this.listSelectItems(dictKey);
		Map<String, String> reverseMap = new HashMap<String, String>();
		for(SelectItem item : items){
			reverseMap.put(item.getValue().toString(), item.getLabel());
		}
		return reverseMap;
	}

}
